from exts import db

# 医生
class Users(db.Model):
    __tablename__ = 'users'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    username = db.Column(db.String(30), nullable=False)
    password = db.Column(db.String(30), nullable=False)
    name = db.Column(db.String(30), nullable=False)
    create_time = db.Column(db.DateTime, nullable=False, server_default=db.func.now(), onupdate=db.func.now(),
                            comment='创建时间')


class Patient(db.Model):
    __tablename__ = 'patient'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.String(30), nullable=False)
    disease = db.Column(db.String(50), nullable=False)
    address = db.Column(db.String(100), nullable=False, comment='省-市-区-xxxxx')
    age = db.Column(db.Integer, nullable=False)
    sex = db.Column(db.Integer, comment='1男2女')
    last_time = db.Column(db.DateTime, comment='最近一次的诊疗时间')
    image_id = db.Column(db.Integer, comment='最近一次的病理图像')
    operator_id = db.Column(db.Integer, comment='创建/更新人')
    operate_time = db.Column(db.DateTime, nullable=False, server_default=db.func.now(), onupdate=db.func.now(),
                             comment='创建/更新时间')


class Image(db.Model):
    __tablename__ = 'image'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    type = db.Column(db.Integer, nullable=False, comment='1单2双')
    pre_address_1 = db.Column(db.String(100), comment='原始图像地址，多分辨率时为低分辨率的')
    pre_address_2 = db.Column(db.String(100), comment='原始图像地址，多分辨率时为高分辨率的')
    post_address = db.Column(db.String(100), comment='处理后图像地址')
    model_kind = db.Column(db.Integer, nullable=False, comment='1:deeplabv3+,2:manet,3:mocov2,4:pixprosw,5:pspnet,6:simclr,7:unet,8:unet++')
    patient_id = db.Column(db.Integer, db.ForeignKey('patient.id'))
    operator_id = db.Column(db.Integer, comment='操作人')
    operate_time = db.Column(db.DateTime, nullable=False, server_default=db.func.now(), onupdate=db.func.now(),
                             comment='操作时间')
    patient = db.relationship('Patient')